import BaseSprite from "../../../Script/Base/BaseSprite";
import MarketUI, { IMarketItem } from "./MarketUI";

const { ccclass, property } = cc._decorator;

@ccclass
export default class MarketItemBag extends BaseSprite {

    @property({ type: cc.Sprite, tooltip: "" })
    private icon: cc.Sprite = null;
    @property({ type: cc.Label, tooltip: "id" })
    private labId: cc.Label = null;
    @property({ type: cc.Label, tooltip: "名字" })
    private labName: cc.Label = null;
    @property({ type: cc.Label, tooltip: "数量" })
    private labNum: cc.Label = null;
    @property({ type: cc.Label, tooltip: "单价" })
    private labSale: cc.Label = null;

    public data: IMarketItem = null;

    public setData(data: IMarketItem) {
        // console.log(data);
        this.data = data;
        this.labId.string = `${data.id}`;
        this.labNum.string = `${data.num}`;
        this.labName.string = `${data.name}`;
        this.labSale.string = `价格: ${data.sale}`;
    }

    private onSelfBtnClicked(event, eventData) {
        // console.log("当前点击的是:", this.data);
        if (this.data) {
            // MarketUI.instance.refreshBag(this.data.id);
            // MarketUI.instance.hideBagViewAnim();
        }
    }
}